package source;

import java.awt.*;
import source.view.*;

/**
 * Unit type that is responsible for creating new bases.
 * @author McDonald's Farmhand
 *
 */
public class Colonist extends Unit {

	/**
	 * Constructor, main responsibility is to call super classes constructor
	 * to assign values to attributes
	 * @param u - the UnitType enumeration value for this Unit
	 * @param status - PlayerStatus object that is to control this Unit
	 * @param tileOn - the beginning Tile for this Unit
	 */
	public Colonist(UnitType u, PlayerStatus status, Tile tileOn) {
		// TODO Auto-generated constructor stub
		super(u, status, tileOn);
	}
	
	/**
	 * Settles a planet with the Colonist. If the base is successfully created,
	 * this Unit is destroyed and a Base is put in it's place. Informs both the
	 * Tile and this Unit's PlayerStatus that this Unit no longer exists and
	 * that a base will be placed in it's stead.
	 * @return true if the base was successfully created; false otherwise
	 */
	public boolean createBase() {
		if (getPosition().hasPlanet()) {
		Base base=new Base(StructureType.BASE, getPlayer(), getPosition());
		Tile tileOn=super.getPosition();
		if(tileOn.settle(base))
		{
		  this.getPlayer().addBase(base);
		  this.destroy();
		  MainScreen.writeToConsole("Colonist: Base created.", Color.MAGENTA);
		}
		return true;
		}
		return false;
	}
	
	/**
	 * Will mine the current tile the colonist is on if it is mineable.
	 * Empty method shell
	 * TODO make not empty
	 */
	public void mine() {
		
	}

}
